package com.aiyige.page.publish.selectinterest.adapter;

import android.view.View;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.publish.selectinterest.model.PublishIndustryItem;
import com.aiyige.page.selectinterest.model.IndustryItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by usera on 2017/11/6.
 */

public class PublishIndustryAdapter extends BaseQuickAdapter<PublishIndustryItem, PublishIndustryAdapter.ViewHolder> {


    public PublishIndustryAdapter() {
        super(R.layout.industry_item, new LinkedList<PublishIndustryItem>());
    }

    @Override
    protected void convert(ViewHolder helper, PublishIndustryItem item) {
        helper.bindData(item);
    }

    public static class ViewHolder extends BaseViewHolder {
        @BindView(R.id.bar)
        View bar;
        @BindView(R.id.block)
        View block;
        @BindView(R.id.titleTv)
        TextView titleTv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(PublishIndustryItem data) {
            if (data.isSelected()) {
                bar.setVisibility(View.VISIBLE);
                block.setVisibility(View.VISIBLE);
            } else {
                bar.setVisibility(View.INVISIBLE);
                block.setVisibility(View.INVISIBLE);
            }
            titleTv.setText(data.getTitle());
        }
    }
}
